/**
  ******************************************************************************
  * @file           : LSM6DSLTR.h
  * @author         : lengq
  * @brief          : None
  * @attention      : None
  * @date           : 2024/4/8
  ******************************************************************************
  */


#ifndef STRESS_DETECTION_LSM6DSLTR_H
#define STRESS_DETECTION_LSM6DSLTR_H


#include "hdl_iic.h"
#include "hdl_gpio.h"
#include "hdl_clk.h"
#include "lsm6dsl_reg.h"

#include "MahonyAHRS.h"
#include "pose.h"
#include "FFT.h"
#include "utils.h"

#include "rtthread.h"

#define    BOOT_TIME                15 //ms
#define    ACC_COLL_CNT_MAX            8
#define    ACC_FIFO_WATERMASK        (ACC_COLL_CNT_MAX * 6)            //采集一秒数据

#define    X                                                0
#define    Y                                                1
#define    Z                                                2
#define    XYZ                                              3

typedef enum
{
	LSM6DSL_IDLE,
	LSM6DSL_INIT,
	LSM6DSL_START,
	LSM6DSL_READ
}en_lsm6dsl_step_t;

typedef struct
{
	en_lsm6dsl_step_t step;
	
	float acc_x;
	float acc_y;
	float acc_z;
	
	float gyro_x;
	float gyro_y;
	float gyro_z;
}stc_lsm6dsl_t;

typedef void (*lsm6dsl_callback_t)(stc_lsm6dsl_t pack_t);

//初始化Lsm6dsltr
void LSM6DSLTR_Init(void);
//设置姿态角0度
void attitudeSetZero(void);

void LSM6DSLTRTask(void);

void LSM6DSLTR_thread_entry(void *parameter);

void lsm6dsl_proc(void);

void lsm6dsl_start(void);

void lsm6dsl_callback_cbs_register(lsm6dsl_callback_t pCBS);

#endif //STRESS_DETECTION_LSM6DSLTR_H
